package chapter8.poly_.detail;
//instanceof 判断是否为当前类的引用，或者当前类的子类的引用.(判断的运行类型)
public class PloyDetail03 {
    public static void main(String[] args) {
        BB bb = new BB();
        System.out.println(bb instanceof BB);
        System.out.println(bb instanceof AA);
        System.out.println(bb instanceof CC);
        AA aa = new BB();
        //判断的为运行类型
        System.out.println(aa instanceof AA);
        System.out.println(aa instanceof BB);
        //若判断的是编译类型，该结果应该为false，因为AA既不是当前类型，也不是BB的子类型
        Object o = new Object();
        System.out.println(o instanceof AA);//false
        String n1 = "0";
        System.out.println(n1 instanceof Object);//true
    }
}

class AA{}
class BB extends AA{}
class CC extends BB{}